package com.exam.xiecheng;

import java.util.Scanner;

/**
 * date:
 * description:
 */
public class Solution004 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String nums = scanner.nextLine();
        String[] numbers = nums.trim().split(" ");
        int n = Integer.parseInt(numbers[0]);
        int m = Integer.parseInt(numbers[1]);
        int q = Integer.parseInt(numbers[2]);
        char[][] matrix = new char[n][m];
        for (int i = 0; i < n; i++) {
            String str = scanner.nextLine().trim().substring(0, m);
            for (int j = 0; j < m; j++) {
                matrix[i][j] = str.charAt(j);
            }
        }
//        int[][] ops = new int[q][4];
        boolean[][] conv = new boolean[n][m];
        for (int i = 0; i < q; i++) {
            int x1 = scanner.nextInt() - 1;
            int y1 = scanner.nextInt() - 1;
            int x2 = scanner.nextInt() - 1;
            int y2 = scanner.nextInt() - 1;
            for (int j = x1; j <= x2; j++) {
                for (int k = y1; k <= y2; k++) {
                    conv[j][k] = !conv[j][k];
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(conv[i][j]){
                    if(matrix[i][j] >= 'a' && matrix[i][j] <= 'z'){
                        matrix[i][j] = Character.toUpperCase(matrix[i][j]);
                    }else{
                        matrix[i][j] = Character.toLowerCase(matrix[i][j]);
                    }
                }
                System.out.print(matrix[i][j]);
            }
            System.out.println();
        }

    }
}
